package com.xszx.controller;

import com.xszx.entity.Echarts;
import com.xszx.entity.TAssettype;
import com.xszx.service.TAssetAssettypeService;
import com.xszx.service.TAssettypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
public class AssetTypeController {

    @Autowired
    private TAssettypeService assettypeService;


    @RequestMapping("/getAssetType")
    @ResponseBody
    public Echarts getAssetType(){

        Echarts echatsRes = new Echarts();
        List<TAssettype> tAssettypes =assettypeService.getAssetType();
        List<String> xlit= new ArrayList<>();
        List<Integer> ylit= new ArrayList<>();
        for (TAssettype tAssettype : tAssettypes) {
            xlit.add(tAssettype.getAtname());
        }
        for (TAssettype tAssettype : tAssettypes) {
            ylit.add(tAssettype.getAtsum());
        }
        echatsRes.setxData(xlit);
        echatsRes.setyData(ylit);
        return echatsRes;
    }

}
